package com.platform.utils;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import org.apache.commons.lang.StringEscapeUtils;

import java.io.IOException;

public class JsonHtmlDeserialize extends JsonDeserializer<String>
{
    @Override
    public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
        String string ="";
        System.out.println("反序列化方法进入:key:"+ jsonParser.getCurrentName()+"value:"+jsonParser.getText());

        //System.out.println(jsonParser);
        try
        {


            if (!"".equals(jsonParser.getText())){
                string = StringEscapeUtils.escapeHtml(jsonParser.getText());
            }


            System.out.println(string);
            return  string;
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
            throw new RuntimeException(e);
        }
    }
}
